package com.artron.mediaartron.ui.fragment.center;

import android.graphics.Color;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.artron.baselib.base.BaseStaticFragment;
import com.artron.mediaartron.R;
import com.artron.mediaartron.ui.helper.TabLayoutHelper;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Class description here
 *
 * @author doing
 * @version 1.0.0
 * @since 2017-11-13.
 */

public class WorksFragment extends BaseStaticFragment {

    @BindView(R.id.WorksFragment_tab)
    protected TabLayout mTabLayout;
    @BindView(R.id.WorksFragment_pager)
    protected ViewPager mViewPager;

    public static WorksFragment newInstance() {
        Bundle args = new Bundle();
        WorksFragment fragment = new WorksFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_works;
    }

    @Override
    protected void initView() {
        FragmentPagerAdapter adapter = new FragmentPagerAdapter(getChildFragmentManager()) {

            final String[] titleArr = {"已完成", "草稿箱"};

            @Override
            public Fragment getItem(int position) {
                if (position == 0) {
                    return WorksFinishFragment.newInstance();
                } else {
                    return WorksDraftFragment.newInstance();
                }
            }

            @Override
            public int getCount() {
                return titleArr.length;
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return titleArr[position];
            }
        };
        mViewPager.setAdapter(adapter);
        mTabLayout.setupWithViewPager(mViewPager);
        mTabLayout.setSelectedTabIndicatorColor(Color.TRANSPARENT);
        TabLayoutHelper.setTabViewMargin(mTabLayout);
    }

}
